package com.qfedu.service.impl;

import com.qfedu.dao.AddressDao;
import com.qfedu.dao.impl.AddressDaoImpl;
import com.qfedu.dao1.AddressDaoByMybatis;
import com.qfedu.entity.Address;
import com.qfedu.service.AddressService;
import com.qfedu.utils.MyBatisUtils;

import java.util.List;

public class AddressServiceImpl implements AddressService {
    private AddressDao addressDao = new AddressDaoImpl();



    private AddressDaoByMybatis addressDaoByMybatis = MyBatisUtils.getSqlSession().getMapper(AddressDaoByMybatis.class);
    @Override
    public List<Address> findAddressById(int uid) {
        return addressDaoByMybatis.findAddressById(uid);
    }

    @Override
    public int addAddress(Address address) {
        return addressDaoByMybatis.addAddress(address);
    }

    @Override
    public int updateAddress(Address address) {
        return addressDaoByMybatis.updateAddress(address);
    }

    @Override
    public int deleteAddress(int aid) {
        return addressDaoByMybatis.deleteAddress(aid);
    }

    @Override
    public int defaultAddr(int aid) {
        return addressDaoByMybatis.defaultAddr(aid);
    }

    @Override
    public int emptyDefault(int uid) {
        return addressDaoByMybatis.emptyDefault(uid);
    }

//    @Override
//    public int setDefault(int aid, int uid) {
//        addressDaoByMybatis.emptyDefault(uid);
//        return addressDaoByMybatis.defaultAddr(aid);
//    }
    //    @Override
//    public List<Address> findAddressById(int uid) throws SQLException {
//        return addressDao.findAddressById(uid);
//    }

//    @Override
//    public List<Address> findAddress() throws SQLException {
//        return addressDao.findAddress();
//    }

//    @Override
//    public int addAddress(Address address) throws SQLException {
//        return addressDao.addAddress(address);
//    }
//
//    @Override
//    public int updateAddress(Address address) throws SQLException {
//        return addressDao.updateAddress(address);
//    }
//
//
//    @Override
//    public int deleteAddress(int aid) throws SQLException {
//        return addressDao.deleteAddress(aid);
//    }
//
//    @Override
//    public int setDefault(int aid,int uid) throws SQLException {
//        //先清空默认地址
//        addressDao.emptyDefault(uid);
//        //再设置默认地址
//        return addressDao.defaultAddr(aid);
//    }

}
